CREATE VIEW [dbo].[vReceiptReport]
AS
SELECT DISTINCT
R.ReceiptKey, R.ReceiptNumber, R.IssuedOn, R.IsNumberAutoGenerated, R.Notes, RL.LineDescription AS ReceiptLineDescription, RL.ReceiptLineKey,
RL.ReceiptedAmount AS ReceiptLineAmount, RTR.ReceiptTitle, RTR.ReceiptTypeDesc, CM.ID, CM.FullName,
AM.FormattedAddress AS ContactAddress
FROM dbo.ReceiptMain R LEFT OUTER JOIN
dbo.ReceiptLine RL ON R.ReceiptKey = RL.ReceiptKey LEFT OUTER JOIN
dbo.ReceiptTypeRef RTR ON R.ReceiptTypeKey = RTR.ReceiptTypeKey LEFT OUTER JOIN
dbo.ContactMain CM ON R.IssuedToContactKey = CM.ContactKey LEFT OUTER JOIN
dbo.FullAddress FA ON CM.ContactKey = FA.ContactKey LEFT OUTER JOIN
dbo.AddressMain AM ON FA.PhysicalAddressKey = AM.AddressKey
GO